


How I modified OrgMaker 2

Robert Hart (Bavi_H) (rnhart.net)
2012-07-16


Here are some notes about how I modified OrgMaker 2. You might find this information useful if you want to make your own changes to OrgMaker 2 or if you want to verify or improve the translations.



[1] Tools I used for modifying OrgMaker 2
[2] Unpacking the executable
[3] Examining or changing text
[3.1] Message boxes
[3.2] Dialog boxes and menus
[4] How OrgMaker 2 loads the Quick Help text
[5] Using Google Translate to translate Japanese to English
[6] Spreadsheet showing translation work





[1] Tools I used for modifying OrgMaker 2

UPX: the Ultimate Packer for eXecutables
http://upx.sourceforge.net/

XN Resource Editor
http://www.wilsonc.demon.co.uk/d10resourceeditor.htm

Resource Hacker
http://www.angusj.com/resourcehacker/

XVI32 Hex Editor 
http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm

Google Translate
http://translate.google.com/



[2] Unpacking the executable

If you want to examine Rxo Inverse's Japanese version of OrgMaker 2 you need to unpack it first. Use UPX: the Ultimate Packer for eXecutables. Make a copy of org205.exe, then use "upx -d org205.exe".

Both Xaser's and my English versions of OrgMaker 2 are not packed.



[3] Examining or changing text


[3.1] Message boxes

To examine the Japanese text in message boxes, use the following procedure.

When the message box is on the screen, press Ctrl+C to copy the text. Paste the text into Notepad and save the file. Drag and drop the text file into your web browser. If the correct Japanese text doesn't appear, go to the page menu or View menu, then go to Encoding and select Japanese (Shift-JIS). Once the correct Japanese text appears, you can then copy it and paste it into Google Translate.

To change the text in the message boxes, use a hex editor. I use XVI32. If you have saved the message box text in Notepad, you can copy a fragment of the text, go to XVI32, open the Find box, paste the text, then click OK to find the location of the text in the executable.

For OrgMaker 2, I've already noted the location of all the text that requires a hex editor to change. In the spreadsheet attachment, use the column "hex offset in unpacked executable" to find the location you need to edit.


[3.2] Dialog boxes and menus

To examine or change dialog boxes and menus, use a resource editor. I used XN Resource Editor and Resource Hacker.

XN Resource Editor will let you copy the Japanese text of most items so you can further translate it with Google Translate or save it in a text file. Some of the characters appear as boxes, but they look okay when you paste them into Google Translate, assuming you have a Japanese font installed.

Unfortunately, XN Resource Editor complains if a menu item has a shortcut key it doesn't understand. Also, it thinks some of the text labels on the QuickSelect toolbar are pictures, so it won't let you copy the text. For those items, I had to find the Japanese text using a hex editor. For a few items, I even had to research resource formats, but I don't remember the details. However, I saved the Japanese text of the difficult-to-copy items in the spreadsheet file.

Resource Hacker just displays ?s for Japanese characters. If you are still examining Japanese text from the executable, be sure not to save with Resource Hacker or else everything will be converted to ?s. Otherwise, Resource Hacker is useful to edit menu items further. You can put any text you want in the shortcut key column of a menu item. Resource Hacker also makes it easier to re-arrange the tab order in dialog boxes, just cut and paste entire lines. However, be sure to "recompile" the script after each change so the preview image and red marker stay in sync with your edits.



[4] How OrgMaker 2 loads the Quick Help text

When you select the Quick Help command from the Help menu, OrgMaker 2 loads the contents of the TEXTHELP resource into a 10,000 byte buffer, adding a CR character (decimal 13, hex 0D) before every LF character (decimal 10, hex 0A). If the buffer overflows, the return address will get overwritten, and when the procedure ends, the program will crash or possibly execute undesired code.

In Windows, copy and paste work best when you use text that has lines ending with CR LF. Programs tend to behave in different ways with other line endings, and since you can't see the line ending characters it can be difficult to tell exactly what's going on.

The original TEXTHELP resource has lines ending with CR LF. Because OrgMaker 2 adds CRs before every LF, the text appearing in the Quick Help dialog box ends up having lines that end in CR CR LF. This can cause problems if you paste into Notepad. (If word wrap is on, Notepad removes CR CR LF sequences when you save, and the saved text will end up having no line ends at all.) If you want to examine the Japanese Quick Help text, you might want to copy it from a resource editor.

I decided to modify OrgMaker 2 so that it doesn't add CRs to the text, and then continued using text with lines ending in CR LF when I modified the TEXTHELP resource. This made it easier to copy and paste, and easier to count bytes to make sure the resource text will fit in the 10,000 byte buffer. (You just have to make sure the number of bytes in the TEXTHELP resource is under 10,000. You don't have to bother with adding an additional CR for every LF in the resource then making sure the total is under 10,000.)


To modify OrgMaker 2 so that it doesn't add CRs to the text:

1. Start with an unpacked OrgMaker executable.

2. In a hex editor, go to offset 57EE. Make sure you see the following values:

80 38 0A 75 04 C6 07 0D 47

3. Change the values to:

90 90 90 90 90 90 90 90 90


Can you increase the buffer size?

I didn't examine the disassembled code in detail, but it looks like the same code is used for multiple functions. The stack size is increased by 10,000 bytes at a single point at the beginning of the function, but seems to be restored to its former size at several different return points. And there's other direct links into the stack that may have to be adjusted. So to properly increase the buffer size, you may need adjust several numbers.



[5] Using Google Translate to translate Japanese to English

Google Translate translates lines separated by Enter individually. If you paste Japanese text that has Enters at the end of every line, you should start your translation process by deleting the Enters in each paragraph or sentence so each piece of text is translated together.

The word order in Japanese and English sentences are different. For longer phrases and sentences, Google Translate has a difficult time rearranging the Japanese words into understandable English phrases. To help you guess a better translation, use the following process.

Hover the mouse pointer over words in the English translation and the corresponding words in the Japanese and English texts will be highlighted. Keep the mouse pointer still so the highlight remains in place and use the arrow keys to move the text cursor to the location of the highlight in the Japanese text. You can now press Enter before or after the Japanese word to break the translation at that point. You can repeatedly separate and rejoin words to get variations of the translation.



[6] Spreadsheet showing translation work

I've never taken a Japanese language class, but using Google Translate to break and rejoin the words I believe I've gotten good translations.

The spreadsheet shows my translation work for many text items so you can check it if you want. You can see the Japanese text, my interpretation of the Google Translate results, the text from Xaser's conversion, and the text I chose for my version. The spreadsheet includes all items that require a hex editor to change. Use the column "hex offset in unpacked executable" to locate the text in the executable. Some items that you change via a resource editor also appear in the spreadsheet, including the items that XN Resource Editor won't let you copy. Other dialog box items can be easily copied using XN Resource Editor, so I didn't bother adding everything to the spreadsheet.



